package us.sunrisemorning.douyuchat;

import java.io.UnsupportedEncodingException;

public class MessageMaker {
	public static MessagePacket loginreq(String roomId) {
		MessagePacket p = new MessagePacket();
		p.setType(MessagePacket.TYPE_CLIENT);
		String message = "type@=loginreq/roomid@=" + roomId + "/\0";
		try {
			p.setBody(message.getBytes(MessagePacket.BODY_CHARSET));
		} catch (UnsupportedEncodingException e) {
			p.setBody(new byte[0]);
		}
		return p;
	}

	public static MessagePacket joingroup(String roomId) {
		MessagePacket p = new MessagePacket();
		p.setType(MessagePacket.TYPE_CLIENT);
		String message = "type@=joingroup/rid@=" + roomId + "/gid@=-9999/\0";
		try {
			p.setBody(message.getBytes(MessagePacket.BODY_CHARSET));
		} catch (UnsupportedEncodingException e) {
			p.setBody(new byte[0]);
		}
		return p;
	}

	public static MessagePacket heartbeat() {
		MessagePacket p = new MessagePacket();
		p.setType(MessagePacket.TYPE_CLIENT);
		String message = "type@=mrkl/\0";
		try {
			p.setBody(message.getBytes(MessagePacket.BODY_CHARSET));
		} catch (UnsupportedEncodingException e) {
			p.setBody(new byte[0]);
		}
		return p;
	}
}
